<template>
	<view class="role-select-container">
		<view class="header">
			<view class="title-container-select">
				<text class="title">生命故事盒子</text>
				<text class="subtitle">请选择您的身份</text>
			</view>
		</view>

		<view class="role-grid">
			<view class="role-item" @click="selectRole('patient')">
				<view class="role-icon patient-icon">
					<text class="iconfont">👤</text>
				</view>
				<text class="role-name">我是患者</text>
			</view>

			<view class="role-item" @click="selectRole('family')">
				<view class="role-icon family-icon">
					<text class="iconfont">👪</text>
				</view>
				<text class="role-name">我是家属</text>
			</view>

			<view class="role-item" @click="selectRole('professional')">
				<view class="role-icon professional-icon">
					<text class="iconfont">👨‍⚕️</text>
				</view>
				<text class="role-name">志愿者</text>
			</view>

			<view class="role-item" @click="selectRole('public')">
				<view class="role-icon public-icon">
					<text class="iconfont">🌍</text>
				</view>
				<text class="role-name">社会公众</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {

		}
	},
	methods: {
		selectRole(role) {
			// 根据角色跳转到不同的页面
			switch (role) {
				case 'patient':
					uni.navigateTo({
						url: '/pages/patient/index'
					});
					break;
				case 'family':
					uni.navigateTo({
						url: '/pages/family/index'
					});
					break;
				case 'professional':
					uni.navigateTo({
						url: '/pages/professional/index'
					});
					break;
				case 'public':
					uni.navigateTo({
						url: '/pages/public/index'
					});
					break;
			}
		}
	}
}
</script>

<style>
.role-select-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 50rpx 40rpx;
	background-image: url('/assets/background.png');
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	height: 100vh;
	box-sizing: border-box;
	position: relative;
}

/* 添加半透明遮罩 */
.role-select-container::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(255, 255, 255, 0.3);
	z-index: 0;
}

.header {
	margin-bottom: 60rpx;
	text-align: center;
	padding-top: 60rpx;
	display: flex;
	justify-content: center;
	position: relative;
	z-index: 1;
	animation: fadeIn 1.2s ease-in-out;
}

.title-container-select {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.title {
	font-size: 52rpx;
	font-weight: bold;
	color: #2e8b57;
	text-shadow: 2rpx 2rpx 4rpx rgba(0, 0, 0, 0.1);
	margin-bottom: 24rpx;
}

.subtitle {
	font-size: 34rpx;
	color: #3cb371;
	letter-spacing: 2rpx;
}

.role-grid {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 30rpx;
	width: 100%;
	max-width: 650rpx;
	margin: 0 auto;
	position: relative;
	z-index: 1;
	animation: fadeIn 0.8s ease-out 0.3s both;
}

.role-item {
	width: 46%;
	background-color: rgba(255, 255, 255, 0.6);
	border-radius: 24rpx;
	padding: 40rpx 20rpx;
	margin-bottom: 40rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.08);
	transition: all 0.3s ease;
	backdrop-filter: blur(5px);
}

.role-item:active {
	transform: scale(0.96) translateY(-5rpx);
	box-shadow: 0 12rpx 24rpx rgba(0, 0, 0, 0.12);
}

.role-icon {
	width: 130rpx;
	height: 130rpx;
	border-radius: 65rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-bottom: 24rpx;
	font-size: 64rpx;
}

.patient-icon {
	background-color: #e6f7ff;
	color: #1890ff;
}

.family-icon {
	background-color: #f6ffed;
	color: #52c41a;
}

.professional-icon {
	background-color: #fff7e6;
	color: #fa8c16;
}

.public-icon {
	background-color: #f9f0ff;
	color: #722ed1;
}

.role-name {
	font-size: 34rpx;
	color: #333;
	font-weight: 500;
}

/* 适配 iPhone 12 Pro 的媒体查询 */
@media screen and (min-width: 390px) and (max-width: 430px) {
	.role-grid {
		max-width: 390px;
	}

	.role-item {
		height: 180rpx;
		justify-content: center;
	}

	.role-icon {
		margin-bottom: 16rpx;
	}
}

/* 适配竖屏模式 */
@media screen and (max-height: 850px) {
	.header {
		margin-bottom: 50rpx;
		padding-top: 40rpx;
	}

	.role-item {
		padding: 30rpx 20rpx;
		margin-bottom: 30rpx;
	}
}

/* 适配安全区域 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
	.role-select-container {
		padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
	}
}

/* 添加动画 */
@keyframes fadeIn {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(50rpx);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}
</style>